﻿using Microsoft.Extensions.Configuration;
using Wechat.Core;
using Wechat.MP.Models;

namespace Wechat.MP.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    public class WechatClientSetting
    {
        /// <summary>
        /// 
        /// </summary>
        const string AUTH_SCOPE = "snsapi_base";
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("name")]
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("appId")]
        public string AppID
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("secretKey")]
        public string SecretKey
        {
            get;
            set;
        }
        /// <summary>
        /// 微信token
        /// </summary>
        [ConfigurationKeyName("token")]
        public string Token
        {
            get;
            set;
        }
        ///// <summary>
        ///// 
        ///// </summary>
        //[ConfigurationKeyName("aesKey")]
        //public string AesKey
        //{
        //    get;
        //    set;
        //}
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("authScope")]
        public string AuthScope
        {
            get;
            set;
        } = AUTH_SCOPE;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="setting"></param>
        public static implicit operator WechatClient(WechatClientSetting setting)
        {
            return new()
            {
                Name = setting.Name,
                AppID = setting.AppID,
                SecretKey = setting.SecretKey,
                Token = setting.Token,
                AuthScope = setting.AuthScope
            };
        }
    }

}